window.onload = function () {
  //配置 请求根路径
  axios.defaults.baseURL = 'http://124.223.14.236:3001/api'
  document.querySelector('form').addEventListener('submit', async function (e) {
    e.preventDefault()
    const username = document.querySelector('#username').value.trim()
    const password = document.querySelector('#password').value.trim()
    const { data } = await axios({
      method: 'POST',
      url: '/user/login',
      data: {
        username,
        password
      }
    })
    console.log(data)
    console.log(data.data.id)
    if (!data.success) return alert(data.msg)
    //拿到id
    localStorage.setItem('id', data.data.id)
    localStorage.setItem('token', data.data.token)
    alert('都登陆成功')

  })
}